import { JSEncrypt } from 'jsencrypt'

const privateKey = ''
const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF8tnVzptBVMxSzkvY5M65e8HOp8Zqa78m8W5UUYMHcaMUVM9zN1a5GY/dN83r2lpNxUkTSgiB6uXzk5e1I0By0bub4ZKmJhX9zE5L5V0V4WORT80yNaCZW4dvETnAgzH2IZEgGYMBcX060kMX6FzB6TCPr+eBhhQpuSd2+HpatQIDAQAB'

export function encryption(txt: any) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt: any) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
